Skip to content

Conversation

JonasKunz
Copy link
Contributor

Very similar to #133381 , but adds support for tracking the exact minimum for exponential histograms:

  • the minimum is required on non-empty exponential histograms
  • If no minimum is provided on ingestion, it will be estimated
  • If the histogram is empty, the minimum must be null

@elasticsearchmachine elasticsearchmachine added v9.2.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Aug 27, 2025
@JonasKunz JonasKunz marked this pull request as ready for review August 27, 2025 12:33
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

histo.tryAddBucket(2, 6, false);
assertThat(toJson(histo), equalTo("{\"scale\":5,\"sum\":1.1,\"negative\":{\"indices\":[-1,2],\"counts\":[4,6]}}"));
assertThat(toJson(histo), equalTo("{\"scale\":5,\"sum\":1.1,\"min\":-0.5,\"negative\":{\"indices\":[-1,2],\"counts\":[4,6]}}"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an example here where sum and min are calculated from the histogram buckets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this tests are only about serialization and don't care about semantic correctness.
For the correctness of aggregates we have tests in ExponentialHistogramMergerTests.java.

valueCount = valueCounts.longValue();
valueSum = NumericUtils.sortableLongToDouble(valueSums.longValue());

if (valueMins != null && valueMins.advanceExact(docId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have sum but not min?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for empty histograms: sum is 0.0, but min is not available.

@JonasKunz JonasKunz enabled auto-merge (squash) August 28, 2025 09:40
@JonasKunz JonasKunz disabled auto-merge August 28, 2025 11:50
@JonasKunz JonasKunz merged commit 9423dcb into elastic:main Aug 29, 2025
33 checks passed
JeremyDahlgren pushed a commit to JeremyDahlgren/elasticsearch that referenced this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :StorageEngine/Mapping The storage related side of mappings Team:StorageEngine v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants